package com.sinosoft.hydra.um.services.component.dataimport.validators;

import com.sinosoft.hydra.um.services.component.dataimport.resolvers.ValidateResult;

/**
 * Created by Administrator on 2015/1/10.
 */
public class NotNullValidator extends Validator{


    private String errorMsg;

    public NotNullValidator() {
    }

    public NotNullValidator(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public ValidateResult validate(Object obj) {
        if(obj == null){
            if(errorMsg != null){
                return ValidateResult.ERROR(errorMsg);
            }
            return ValidateResult.ERROR("数据不能为空");
        }
        return ValidateResult.PASS();
    }
}
